//
//  WJLiveCourseCollectionItem.m
//  CollectionViewDemo
//
//  Created by wangjie on 2018/6/7.
//  Copyright © 2018年 I just want to be a quiet and handsome man. All rights reserved.
//

#import "WJLiveCourseCollectionItem.h"
#import <Masonry.h>
#import "WJLiveCourseItemModel.h"

@interface WJLiveCourseCollectionItem ()
@property (nonatomic,strong)UILabel * titleLab;
@property (nonatomic,strong)UIImageView * leftIcon;

@end


@implementation WJLiveCourseCollectionItem

#pragma mark - 懒加载

-(UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc]init];
        _titleLab.font = [UIFont systemFontOfSize:10];
    }
    return _titleLab;
}


- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self createUI];
    }
    return self;
}

- (void)createUI{
    self.backgroundColor = UIColor.groupTableViewBackgroundColor;
    self.leftIcon = [[UIImageView alloc]init];
    [self addSubview:self.leftIcon];
    [self.leftIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@5);
        make.width.height.equalTo(@16);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftIcon.mas_right).offset(5);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
}


- (void)setModel:(WJLiveCourseItemModel *)model{
    _model = model;
    if (model.isSel) {
        self.leftIcon.image = [UIImage imageNamed:@"sel"];
    }else{
        self.leftIcon.image = [UIImage imageNamed:@"normal"];
    }
    self.titleLab.text = model.title;
}


@end
